-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: hoisting #14
base: master
Are you sure you want to change the base?
WIP: hoisting #14
Conversation
The '-predicates' flag is necessary due to the issue here: janestreet-deprecated/ppx_core#1 While the recommended fix is to edit the local _tags file, that introduces a hard dependency on OCaml >= 4.02 due to some changes in the ocamlbuild _tags syntax. To maintain compatibility with older OCaml versions, specify the -predicates build flag as done here.
On Wed, Mar 02, 2016 at 10:38:40PM -0800, Josh Allmann wrote:
Looking at it (but I only know a little more ppx than last week, mostly from
I had already assumed it would become difficult to support ppx without I think it's acceptable to drop ppx support for 4.02.[12]: it's never been So unless somebody else comes up with a good reason not to, AFAIAC you can
Is Pstr_eval of any practical significance? If I understand it correctly, it's As for Pstr_class, you could argue that you're not very concerned about They're minor use cases for a minor optimization, not worth the trouble if
Cannot really say a lot about idiomatic ppx uses, as a non-ppx-user-yet... Mauricio Fernández |
Not really intended for merging, just a preview of work so far -- I'm still learning ppx too. Feedback welcome.
Firstly, this adds a dependency on
Ppx_core
for AST folding. The setup for that is quite complex (thanks @Drup for help with this and all my other ppx questions...). The biggest issue is that I think usingPpx_core
introduces a transitive dependency on OCaml >= 4.02.3, which is probably undesirable forsqlexpr
. I can either try reworking the opam/oasis files to compile ppx only conditionally (hopefully that's possible?), or implement a fold using OCaml'sAst_iterator
.The ppx tests for sqlexpr all pass, but this doesn't yet hoist everything that
pa_estring
does: handling forPstr_eval
andPstr_class
are missing. The latter simply hasn't been done yet, and the former [1] leads to some very strange interactions with Lwt bindings [2]. (Probably a bug on my end, but I haven't figured it out yet...)Also there are no tests explicitly for hoisting, but the regular test suite seems to stress the mechanism pretty well, I think. Probably should add some more tests once
Pstr_eval
andPstr_class
get added in.Finally, a thought I had while implementing this: it might be more idiomatic to use an annotation alongside the
[%sql ...]
declaration, eg[@cached]
or similar, rather than defining[%sqlc ...]
as a separate extension. Since the work for[%sqlc ...]
has been done already, probably doesn't matter too much.[1] j0sh@e828cff
[2] https://gist.github.com/j0sh/434844532f67e87ffb60#file-broken-ml-L31-L42